home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_d / tpop3.zip / WINSOCK.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-10  |  8KB  |  176 lines

  1. unit WINSOCK;
  2.  
  3. { Winsock.h file for Borland Pascal
  4.   Conversion by Marc B. Manza
  5.              Center for Applied Large-Scale Computing
  6.   Requires Winsock.pas and Winsock.inc
  7.  
  8.   Send any comments/change requests/etc. to:
  9.   manza@flash.poly.edu }
  10.  
  11. {
  12.   Modified by Mike Caughran Cedar Island Software
  13.   Added gethostname.
  14.   changed _socket() to socket().
  15.   changed references to SOCKET to tSOCKET.
  16.   changed accept parms from tSocket,SockAddr,Integer 
  17.                          to tSocket,PSockAddr,PInteger
  18. }
  19.  
  20. interface
  21.  
  22. uses Messages, WinTypes, WinProcs;
  23.  
  24. {$I winsock.inc }
  25. {.$R errno.res}
  26.  
  27. { Library Functions }
  28.  
  29.   function accept (s : tSOCKET; addr : PSockaddr; addrlen : PInteger) : tSOCKET;
  30.   function bind (s : tSOCKET; addr : sockaddr; namelen : integer) : integer;
  31.   function closesocket (s : tSOCKET) : integer;
  32.   function connect (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  33.   function ioctlsocket (s : tSOCKET; cmd : longint; argp : u_long) : integer;
  34.   function getpeername (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  35.   function getsockname (s : tSOCKET; name : sockaddr; namelen : integer) : integer;
  36.   function getsockopt (s : tSOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  37.   function htonl (hostlong : u_long) : u_long;
  38.   function htons (hostshort : u_short) : u_short;
  39.   function inet_addr (cp : PChar) : PIn_Addr;  { in_addr }
  40.   function inet_ntoa (inaddr : in_addr) : PChar;
  41.   function listen (s : tSOCKET; backlog : integer) : integer;
  42.   function ntohl (netlong : u_long) : u_long;
  43.   function ntohs (netshort : u_short) : u_short;
  44.   function recv (s : tSOCKET; buf : PChar; len, flags : integer) : integer;
  45.   function recvfrom (s : tSOCKET; buf : PChar; len, flags : integer; from : sockaddr; fromlen : integer) : integer;
  46.   function select (nfds : integer; readfds, writefds, exceptfds : fd_set; timeout : timeval) : longint;
  47.   function send (s : tSOCKET; buf : PChar; len, flags : integer) : integer;
  48.   function sendto (s : tSOCKET; buf : PChar; len, flags : integer; addrto : sockaddr; tolen : integer) : integer;
  49.   function setsockopt (s : tSOCKET; level, optname : integer; optval : PChar; optlen : integer) : integer;
  50.   function shutdown (s : tSOCKET; how : integer) : integer;
  51.   function socket (af, struct, protocol : integer) : tSOCKET;
  52.   function gethostbyaddr (addr : PChar; len, struct : integer) : PHostEnt; { hostent }
  53.   function gethostbyname (name : PChar) : PHostEnt; { hostent }
  54.   function gethostname (name : PChar; len : integer) : integer;
  55.   function getservbyport (port : integer; proto : PChar) : PServEnt; { servent }
  56.   function getservbyname (name, proto : PChar) : PServEnt; { servent }
  57.   function getprotobynumber (proto : integer) : PProtoEnt; { protoent }
  58.   function getprotobyname (name : PChar) : PProtoEnt; { protoent }
  59.   function WSAStartup (wVersionRequired : word; lpWSData : LPWSADATA) : integer;
  60.   function WSACleanup : integer;
  61.   procedure WSASetLastError (iError : integer);
  62.   function WSAGetLastError : integer;
  63.   function WSAIsBlocking : BOOL;
  64.   function WSAUnhookBlockingHook : integer;
  65.   function WSASetBlockingHook (lpBlockFunc : TFarProc) : TFarProc;
  66.   function WSACancelBlockingCall : integer;
  67.   function WSAAsyncGetServByName (HWindow : HWND; wMsg : u_int; name, proto, buf : PChar; buflen : integer) : THandle;
  68.   function WSAAsyncGetServByPort ( HWindow : HWND; wMsg, port : u_int; proto, buf : PChar; buflen : integer) : THandle;
  69.   function WSAAsyncGetProtoByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  70.   function WSAAsyncGetProtoByNumber (HWindow : HWND; wMsg : u_int; number : integer;
  71.                                       buf : PChar; buflen : integer) : THandle;
  72.   function WSAAsyncGetHostByName (HWindow : HWND; wMsg : u_int; name, buf : PChar; buflen : integer) : THandle;
  73.   function WSAAsyncGetHostByAddr (HWindow : HWND; wMsg : u_int; addr : PChar; len, struct : integer;
  74.                                   buf : PChar; buflen : integer) : THandle;
  75.   function WSACancelAsyncRequest (hAsyncTaskHandle : THandle) : integer;
  76.   function WSAAsyncSelect (s : tSOCKET; HWindow : HWND; wMsg : u_int; lEvent : longint) : integer;
  77.  
  78.  
  79. function WSAMakeSyncReply (Buflen, Error : Word) : LongInt;
  80. function WSAMakeSelectReply (Event, Error : Word) : LongInt;
  81. function WSAGetAsyncBuflen (Param : LongInt) : Word;
  82. function WSAGetAsyncError (Param : LongInt) : Word;
  83. function WSAGetSelectEvent (Param : LongInt) : Word;
  84. function WSAGetSelectError (Param : LongInt) : Word;
  85.  
  86. implementation
  87.  
  88. var
  89.    fdSet : fd_set;
  90.  
  91. function FIONBIO (x, y : integer; t : u_long) : u_long;
  92. begin
  93.      FIONBIO := (IOC_IN OR ((IOCPARM_MASK shl 16) OR (x SHL 8) OR (Y)));
  94. end;
  95.  
  96. function WSAMakeSyncReply;
  97. begin
  98.      WSAMakeSyncReply := MakeLong (Buflen, Error);
  99. end;
  100.  
  101. function WSAMakeSelectReply;
  102. begin
  103.      WSAMakeSelectReply := MakeLong (Event, Error);
  104. end;
  105.  
  106. function WSAGetAsyncBuflen;
  107. begin
  108.      WSAGetAsyncBuflen := LOWORD(Param);
  109. end;
  110.  
  111. function WSAGetAsyncError;
  112. begin
  113.      WSAGetAsyncError := HIWORD(Param);
  114. end;
  115.  
  116. function WSAGetSelectEvent;
  117. begin
  118.      WSAGetSelectEvent := LOWORD(Param);
  119. end;
  120.  
  121. function WSAGetSelectError;
  122. begin
  123.      WSAGetSelectError := HIWORD(Param);
  124. end;
  125.  
  126. function accept;            external    'WINSOCK' index 1;
  127. function bind;              external    'WINSOCK' index 2;
  128. function closesocket;       external    'WINSOCK' index 3;
  129. function connect;           external    'WINSOCK' index 4;
  130. function getpeername;       external    'WINSOCK' index 5;
  131. function getsockname;       external    'WINSOCK' index 6;
  132. function getsockopt;        external    'WINSOCK' index 7;
  133. function htonl;             external    'WINSOCK' index 8;
  134. function htons;             external    'WINSOCK' index 9;
  135. function inet_addr;         external    'WINSOCK' index 10;
  136. function inet_ntoa;         external    'WINSOCK' index 11;
  137. function ioctlsocket;       external    'WINSOCK' index 12;
  138. function listen;            external    'WINSOCK' index 13;
  139. function ntohl;             external    'WINSOCK' index 14;
  140. function ntohs;             external    'WINSOCK' index 15;
  141. function recv;              external    'WINSOCK' index 16;
  142. function recvfrom;          external    'WINSOCK' index 17;
  143. function select;            external    'WINSOCK' index 18;
  144. function send;              external    'WINSOCK' index 19;
  145. function sendto;            external    'WINSOCK' index 20;
  146. function setsockopt;        external    'WINSOCK' index 21;
  147. function shutdown;          external    'WINSOCK' index 22;
  148. function socket;            external    'WINSOCK' index 23;
  149.  
  150. function gethostbyaddr;     external    'WINSOCK' index 51;
  151. function gethostbyname;     external    'WINSOCK' index 52;
  152. function getprotobyname;    external    'WINSOCK' index 53;
  153. function getprotobynumber;  external    'WINSOCK' index 54;
  154. function getservbyname;     external    'WINSOCK' index 55;
  155. function getservbyport;     external    'WINSOCK' index 56;
  156. function gethostname;       external    'WINSOCK' index 57;
  157.  
  158. function WSAAsyncSelect;    external    'WINSOCK' index 101;
  159. function WSAAsyncGetHostByAddr; external 'WINSOCK' index 102;
  160. function WSAAsyncGetHostByName; external 'WINSOCK' index 103;
  161. function WSAAsyncGetProtoByNumber; external 'WINSOCK' index 104;
  162. function WSAAsyncGetprotoByName; external 'WINSOCK' index 105;
  163. function WSAAsyncGetServByPort; external 'WINSOCK' index 106;
  164. function WSAAsyncGetServByName; external 'WINSOCK' index 107;
  165. function WSACancelAsyncRequest; external 'WINSOCK' index 108;
  166. function WSASetBlockingHook; external    'WINSOCK' index 109;
  167. function WSAUnhookBlockingHook; external 'WINSOCK' index 110;
  168. function WSAGetLastError;    external    'WINSOCK' index 111;
  169. procedure WSASetLastError;   external    'WINSOCK' index 112;
  170. function WSACancelBlockingCall; external 'WINSOCK' index 113;
  171. function WSAIsBlocking;     external     'WINSOCK' index 114;
  172. function WSAStartup;        external     'WINSOCK' index 115;
  173. function WSACleanup;        external     'WINSOCK' index 116;
  174.  
  175. end.
  176.